package org.ctd.springframework.beans.factory.xml;

import com.ctd.springframework.core.io.Resource;
import org.ctd.springframework.beans.factory.BeanFactory;
import org.ctd.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * xml beanFactory
 *
 * @author chentudong
 * @time 2019/3/24 20:04
 */
public class XmlBeanFactory extends DefaultListableBeanFactory {
    private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this);

    /**
     * 根据resource 配置bean
     *
     * @param resource
     */
    public XmlBeanFactory(Resource resource) {
        this(resource, null);
    }

    /**
     * 根据resource parentBeanFactory 配置bean
     *
     * @param resource          resource
     * @param parentBeanFactory parentBeanFactory
     */
    public XmlBeanFactory(Resource resource, BeanFactory parentBeanFactory) {
        super(parentBeanFactory);
        this.reader.loadBeanDefinitions(resource);
    }
}
